﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Baosight.ZNH.ZMCommon;
using Baosight.Platform.Core.UI.Controls;
using Baosight.Platform.Core;
using Baosight.Platform.Core.ServiceModel;
using Telerik.Windows.Controls;
using Telerik.Windows.Controls.GridView;
using Baosight.ZNH.ZMCommon.ChildWindows;
using Baosight.ZNH.ZMCB.UI.Utils;

namespace Baosight.ZNH.ZMCB.UI
{
    /// <summary>
    /// 查询中长期计划-主表
    /// </summary>
    /// Copyright:Baosight Software LTD.co Copyright (c) 2011
    /// Company:上海宝信软件股份有限公司
    /// Author: 梁琦
    /// Version: 1.0
    /// History:
    ///       2013-07-08  梁琦   [创建]
    ///
    public partial class ZMCBE0 : EFViewCmes
    {

        public ZMCBE0()
        {
            InitializeComponent();
            base.BeforeAction += OnBeforeAction;
        }

        /// <summary>
        /// 列表中修改、删除前设置属性、参数
        /// 传递到后台代码
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnBeforeAction(object sender, EventArgs e)
        {
            EFViewCmesProperty _view = new EFViewCmesProperty();
            _view.EFGridCheckedRows = this.grid.GetCheckedEIRows();
            base.ViewProperty = _view;
        }

        public override void Initialize(EIInfo initData)
        {
            YearPlanFTBlock block = new YearPlanFTBlock();
            initData.AddBlock(block.GetPlanStatus());
            base.Initialize(initData);
        }
        /// <summary>
        /// 选中主表一条记录，显示该条记录的从表数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void grid_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)
        {
            if (null != this.grid.SelectedItem)
            {
                EIRow _row = (this.grid.SelectedItem as UIBaseEntity).GetEIRow();

                Dictionary<string, string> args = new Dictionary<string, string>();
                args.Add("fdForeignKey", _row["fdKeyId"].ToString());
                this.container.LoadView<EFCustomViewContainerPanel>("ZMCBC1", args);
            }
            else
            {
                this.container.Content = null;
            }
        }



        /// <summary>
        /// 明细
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void HyperlinkButton_Click(object sender, RoutedEventArgs e)
        {
            HyperlinkButton link = sender as HyperlinkButton;
            String fdKeyId = (link.ParentOfType<GridViewRow>().Item as UIBaseEntity).GetEIRow()["fdKeyId"].ToString();
            Dictionary<string, string> args = new Dictionary<string, string>();

            args.Add("fdKeyId", fdKeyId);
            Shell.LoadView("ZMCB20", args);
        }
    }
}
